{% load static %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>缺失值处理</title>
    <base href="/">
    <link rel="SHORTCUT ICON" href="../static/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../static/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/footer.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/dataAnalysis.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/progressBar.css"/>
    <script type="text/javascript" src="../static/js/jquery-2.1.1.min.js"></script>
    <style>
        a {
            text-decoration: none;
        }

        body {
            background: #F6F8FA;
        }


        .nav {
            background-color: #34495e;
            height: 80px;
            width: 1330px;
            margin-left: 5px;
            margin-right: 5px;

        }

        .main-middle {
            height: 960px;
            background-color: #fff;
            margin-top: 5px;
            margin-left: 7px;
            margin-right: 12px;
        }

        .footer {
            width: 1330px;
            background-color: #34495e;
            margin-top: 5px;
            height: 80px;
            margin-left: 7px;
            margin-bottom: 5px;
        }

        .logo {
            width: 250px;
            height: 80px;
            background-color: #aee6a6;
            margin-left: 10px;
        }

        .logo img {
            width: 250px;
            height: 80px;
        }

        .content_left {
            background-color: #f2f2f2;
            width: 300px;
            height: 955px;
            float: left;
        }

        .upload_file {
            width: 290px;
            height: 130px;
            background-color: #dfdfdf;
            margin-left: 5px;
            text-align: center;
        }

        .select {
            width: 290px;
            height: 135px;
            background-color: #dfdfdf;
            margin-left: 5px;
            text-align: center;
            margin-top: 5px;
        }

        .download {
            width: 290px;
            height: 90px;
            background-color: #dfdfdf;
            margin-left: 5px;
            text-align: center;
            margin-top: 5px;
        }

        .content_right {
            background-color: #f2f2f2;
            height: 950px;
            width: 1023px;
            margin-left: 5px;
            margin-right: 2px;
            float: right;
            margin-top: 5px;

        }

        .content_right {
            text-align: center;
        }

        .data_table tr:nth-child(n+1) {
            background: #a6d481;
        }

        .data_table tr:nth-child(2n) {
            background: #d5eecc;
        }

        .show_data {
            margin-left: 5px;
            margin-top: 5px;
            background-color: #F8FCFD;
            width: 1000px;
            height: 290px;
            overflow-x: auto;
            overflow-y: auto;
            margin-bottom: -40px;

        }

        .data_detail {
            margin-left: 5px;
            margin-top: 5px;
            background-color: #F8FCFD;
            width: 1000px;
            height: 150px;
            margin-bottom: 15px;

        }

        .data_table {
            white-space: nowrap;
        }

        .data_distribution {
            margin-left: 5px;
            margin-top: 5px;
            background-color: #f2f2f2;
            width: 1000px;
            height: 450px;
        }

        .right_img img {
            width: 490px;
            height: 330px;
        }

        .left_img img {
            width: 490px;
            height: 330px;
        }

        .show_img img {
            width: 700px;
            height: 400px;
            margin-top: 5px;
        }

        /** Table 表格样式 **/
        .data_table {
            border-collapse: collapse;
            width: 100%;
            border: 1px solid #c6c6c6 !important;
            margin-bottom: -35px;
        }

        .data_table th {
            border-collapse: collapse;
            border-right: 1px solid #c6c6c6 !important;
            border-bottom: 1px solid #c6c6c6 !important;
            background-color: #ddeeff !important;
            padding: 5px 9px;
            font-size: 14px;
            font-weight: normal;
            text-align: center;
        }

        .data_table td {
            border-collapse: collapse;
            border-right: 1px solid #c6c6c6 !important;
            border-bottom: 1px solid #c6c6c6 !important;
            padding: 5px 9px;
            font-size: 12px;
            font-weight: normal;
            text-align: center;
            word-break: break-all;
        }

        .data_table tr:nth-child(odd) {
            background-color: #fff !important;
        }

        .data_table tr:nth-child(even) {
            background-color: #f8f8f8 !important;
        }

        .data_table1 {
            margin-top: 50px;
        }

        .user_input {
            outline-style: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            padding: 3px;
            width: 130px;
            font-size: 14px;
            font-weight: 300;
        }

        .user_submit {
            outline-style: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            width: 110px;
            font-size: 14px;
            font-weight: 300;
            background: #4ca2ec;
            visibility: visible;
            padding: 3px;
            border-bottom-color: #2B562B;
            cursor: pointer;
            text-decoration: none;
            color: #FFF;
            text-shadow: 0 1px 0 #5d4113;
        }

        .user_submit:hover {
            background-color: #4687b1;
        }

        input:focus {
            border-color: #66afe9;
            outline: 0;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6)
        }

        select {
            padding: 3px;
            width: 138px;
            float: left;
            border-radius: 1px;
            font-size: 14px;
            font-weight: 300;
            margin-top: 5px;
            margin-bottom: 5px;
        }

        .update {
            width: 110px;
            height: 30px;
            cursor: pointer;
            font-size: 14px;
            border-radius: 2px;
            border: none;
            background-color: #4ca2ec;
            color: #fff;
            line-height: 30px;
        }

        .update:hover {
            background-color: #4687b1;
        }

        .select_file {
            width: 180px;
            height: 30px;
            cursor: pointer;
            font-size: 14px;
            border-radius: 2px;
            border: none;
        }

        .download input {
            width: 110px;
            height: 30px;
            cursor: pointer;
            font-size: 14px;
            border-radius: 2px;
            border: none;
            background-color: #4ca2ec;
            color: #fff;
            line-height: 30px;
            margin-top: 5px;
        }

        .download input:hover {
            background-color: #4687b1;
        }
    </style>
</head>
<body>
<div class="nav">
    <div class="logo">
        <img src="../static/img/logo.jpg">
    </div>
</div>
<nav>
    <!--导航条-->
    <ul class="nav-main">
        <li><a href="/">首页</a></li>
        <li id="li-1">在线数据分析<span></span></li>
        <li id="li-2">数据社区<span></span></li>
        <li id="li-3">数据可视化<span></span></li>
        <li><a href="/contact/">关于我们</a></li>
        <li><a href="/help/">帮助中心</a></li>
    </ul>
    <div id="box-1" class="hidden-box hidden-loc-index">
        <ul>
            <li><a href="/analysis/">数据分析</a></li>
        </ul>
    </div>
    <div id="box-2" class="hidden-box hidden-loc-us">
        <ul>
            {% for catagory in allcategory %}
                <li><a href="{% url 'index' %}blog/list{{ catagory.id }}">{{ catagory.nama }}</a></li>
            {% endfor %}
        </ul>
    </div>
    <div id="box-3" class="hidden-box hidden-loc-info">
        <ul>
            <li><a href="/visualization/bar/">数据可视化</a></li>
        </ul>
    </div>
</nav>
<div class="main-middle">
    <div class="content_left">
        <div class="upload_file">
            <h4 style="margin-bottom: 5px">上传CSV数据集</h4>
            <form action="/dataAnalysis/show_missdata/" method="post" enctype="multipart/form-data">
                {% csrf_token %}
                <input type="file" required class="select_file" name="csv_file">
                <p></p>
                <input type="submit" class="update" value="上传CSV数据集">
                                <p style="color: #2021ec">{{ message }}</p>
                                <p style="color: #c9302c">{{ err_message }}</p>
            </form>
{#            <div style="width:286px;height:44px;">#}
{#                <!-- 进度条 -->#}
{#                <div class="barline" id="probar">#}
{#                    <div id="percent"></div>#}
{#                    <div id="line" w="100" style="width:0px;"></div>#}
{#                    <div id="msg" style=""></div>#}
{#                </div>#}
{#            </div>#}
        </div>
        <div class="select">
            <h4 style="margin-bottom: 5px">缺失值处理</h4>
            <form action="/dataAnalysis/miss_handle/" method="post">
                {% csrf_token %}
                <table border="0" cellspacing="0" cellpadding="0" style="margin: auto;">
                    <tr>
                        <td style="margin-top: 5px;">输入图表标题</td>
                        <td><input id="title" required class="user_input" type="text" name="title" placeholder="请输入图表标题"></td>
                    </tr>
                    <tr>
                        <td><select name="chart_values">
                            <option selected="selected">选择图表类型</option>
                            <option value="matrix">矩阵图</option>
                            <option value="bar">柱状图</option>
                            <option value="heatmap">热力图</option>
                        </select>
                        </td>
                        <td><select name="miss_values">
                            <option selected="selected">处理缺失值方式</option>
                            <option value="mean">平均值填补</option>
                            <option value="median">中位数填补</option>
                            <option value="mode">众数填补</option>
                            <option value="delete_miss">删除缺失值</option>
{#                            <option value="inter">插值法填补</option>#}
                        </select></td>
                    </tr>
                    <tr>
                        <td><input class="user_submit" id="submit" type="submit" value="确认"></td>
                    </tr>
                </table>
                <p style="color: #4DBF7D">{{ msg }}</p>
                <p style="color: #c9302c">{{ err_msg }}</p>
            </form>
        </div>
        <div class="download">
            <h4>导出CSV数据集</h4>
            <p></p>
            <form action="/dataAnalysis/download/" method="post">
                {% csrf_token %}
                <input type="submit" value="导出CSV数据集"/>
            </form>
        </div>

    </div>
    <div class="content_right">
        <div class="show_data">
            <table border="0" cellspacing="0" cellpadding="0" width="950px" height="270px" class="data_table">
                <caption style="height: 30px;font-size: 18px;background-color: #f2f2f2;line-height: 30px">数据预览</caption>
                {% for line in test_data %}
                    <tr>
                        {% for i in line %}
                            <td>{{ i }}</td>
                        {% endfor %}
                    </tr>
                {% endfor %}
            </table>
        </div>
        <div class="data_detail" style="overflow-x: auto;overflow-y: auto">
            <table border="1" cellspacing="0" cellpadding="0" width="500px" height="100px"
                   class="data_table data_table1">
                <caption style="height: 30px;font-size: 18px;background-color: #f2f2f2;line-height: 30px;">数据缺失预览
                </caption>
                <tr>
                    <td>列名</td>
                    {% for key,value in miss_data.items %}
                        <td>{{ key }}</td>
                    {% endfor %}
                </tr>
                <tr>
                    <td>是否缺失</td>
                    {% for key,value in miss_is_or_not.items %}
                        <td>{{ value }}</td>
                    {% endfor %}
                </tr>
                <tr>
                    <td>缺失数量</td>
                    {% for key,value in miss_data.items %}
                        <td>{{ value }}</td>
                    {% endfor %}
                </tr>
                <tr>
                    <td>缺失比例</td>
                    {% for key,value in miss_ratios.items %}
                        <td>{{ value }}</td>
                    {% endfor %}
                </tr>
                <tr>
                    <td>缺失行</td>
                    <td>{{ miss_rows }}</td>
                    <td>缺失率</td>
                    <td>{{ miss_ratio }}</td>
                    <td>数据集规模</td>
                    <td>{{ dataSize }}</td>
                    <td></td>
                </tr>
            </table>
        </div>
        <div class="data_distribution">
            <div class="show_img">
                <img src="{{ src }}" alt="缺失值柱状图"/>
            </div>
        </div>
    </div>
</div>
<div class="footer">
    <footer style="border-top: 1px solid ; background-repeat: repeat;"
            class="footer">
        <div class="footer-inner">
            <div class="fooert copyright" align="center">
                <a href="##" target="_blank">友情链接：</a>
                <a href="https://www.django.cn/" target="_blank">Django中文网</a>
                | <a href="https://www.runoob.com/" target="_blank">菜鸟教程</a>
                | <a href="http://pyecharts.org/#/zh-cn/" target="_blank">pyecharts</a> |
                <a href="http://sc.chinaz.com/tag_jiaoben/tupianlunbo.html" rel="sitemap">站长素材</a>
                | <a href="##" target="_blank">联系我们</a>
                <p><a href="/" title="dry">dry</a> 版权所有，保留一切权利 ! <a href="https://www.kkkuu.cn/">首页</a> © 2019-2020 ·
                    黔ICP备00000000号</p>
            </div>
    </footer>
</div>
<script src="../static/js/index.js"></script>
<script language="javascript">
    setTimeout(function () {
        $("#probar").delay(9000).hide(0);
    });

    function processerbar(time) {
        document.getElementById('probar').style.display = "block";
        $("#line").each(function (i, item) {
            var a = parseInt($(item).attr("w"));
            $(item).animate({
                width: a + "%"
            }, time);
        });
        var si = window.setInterval(
            function () {
                a = $("#line").width();
                b = (a / 200 * 100).toFixed(0);
                document.getElementById('percent').innerHTML = b + "%";
                document.getElementById('percent').style.left = a - 12 + "px";
                document.getElementById('msg').innerHTML = "上传中";
                if (document.getElementById('percent').innerHTML === "100%") {
                    clearInterval(si);
                    document.getElementById('msg').innerHTML = "&nbsp;&nbsp;成功";
                }
            }, 70);
    };
</script>

<script>
    var oTxt = document.getElementById('title');

    var oBtn = document.getElementById('submit');

    function isnull(val) {

        var str = val.replace(/(^\s*)|(\s*$)/g, '');//去除空格;

        if (str === '' || str === undefined || str == null) {
            //return true;
            console.log('空')
        } else {
            //return false;
            console.log('非空');
        }
    }

    oBtn.onclick = function () {

        isnull(oTxt.value);
    }

</script>
</body>
</html>